<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:a="livcos.org/ns/admin"
	xmlns:f="livcos.org/ns/xslt/function"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:v="livcos.org/ns/view"
	exclude-result-prefixes="a f v">
	
	<xsl:import href="../../../../base.xsl"/>
	
	<xsl:template match="a:address">
		<a id="{@id}" class="address" title="See in Google Maps"
			href="http://maps.google.com?q={a:street},{a:house},{a:city},{a:country}" target="_blank">
			<v:style ref="{resolve-uri('styles.css')}"/>
			<img class="map" src="{f:caller-uri(resolve-uri('../../../../../img/map.png'))}"/>
			<p><xsl:value-of select="a:street"/>&#160;<xsl:value-of select="a:house"/></p>
			<p>
				<xsl:value-of select="a:country"/>
				<xsl:text>-</xsl:text>
				<xsl:value-of select="a:zip | a:zipCode"/>&#160;<xsl:value-of select="a:city"/>
			</p>
		</a>
	</xsl:template>
	
	<xsl:template match="a:address[@ref]">
		<xsl:apply-templates select="f:entity(@ref)"/>
	</xsl:template>
	
	<xsl:template match="a:phone">
		<span id="{@id}" class="phone">
			<v:style ref="{resolve-uri('styles.css')}"/>
			<xsl:variable name="img">
				<xsl:choose>
					<xsl:when test="@net = 'fixed'">phone.png</xsl:when>
					<xsl:when test="@net = 'mobile'">mobile.png</xsl:when>
					<xsl:otherwise>phone.png</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<img src="{f:caller-uri(resolve-uri(concat('../../../../../img/',$img)))}" height="14pt"/>
			<xsl:text> +</xsl:text>
			<xsl:value-of select="@country" />
			<xsl:text> (0</xsl:text>
			<xsl:value-of select="@area" />
			<xsl:text>) </xsl:text>
			<xsl:value-of select="substring(@number,1,3)" />
		  <xsl:text>&#160;</xsl:text>
		  <xsl:value-of select="substring(@number,4)" />
		</span>
	</xsl:template>
	
	<xsl:template match="a:email">
		<span id="{@id}" class="email">
			<v:style ref="{resolve-uri('styles.css')}"/>
			<a href="#" title="send mail">
		    <xsl:attribute name="onclick">
		      <xsl:text>this.href='ma'+'ilto/'.replace('/',':')+'</xsl:text>
		      <xsl:value-of select="@name" />
		    	<xsl:text>'+''+String.fromCharCode(64)+'</xsl:text>
		      <xsl:value-of select="replace(@domain, '\.', '/')" />
		      <xsl:text>'.replace('/', '.')+''</xsl:text>
		    </xsl:attribute>
				<img src="{f:caller-uri(resolve-uri('../../../../../img/mail.png'))}"/>
		    <xsl:text>&#160;</xsl:text>
		    <xsl:value-of select="@name"/>
		    <span style="display:none">abc</span>
		  	<span></span>
		  	<span>@</span>
		  	<span style="display:none">abc</span>
		    <xsl:value-of select="@domain" />
		  </a>
		</span>
	</xsl:template>
	
</xsl:stylesheet>
